
// 致力于将所有的请求整合到一个文件中(api.js), 方便后期管理

// 此写法将Promise请求部分分离出来 => 存放到当前文件, 当引入api.js时会立即发送请求,且没有结果处理 => 有问题
// ajaxPromise({
//     type: "get",
//     url: "http://121.43.116.41/demo/php/isExistUser.php",
//     data: {
//         user,
//     },
//     dataType: "json",
// })
// ajaxPromise({
//     type: "get",
//     url: "http://121.43.116.41/demo/php/isExistUser.php",
//     data: {
//         user,
//     },
//     dataType: "json",
// })


// 解决方法: 对应请求的功能进行二次封装  => 嵌套一层函数( 1.请求可以复用  2.函数调用时才会发送请求)

// 调用此方法时,发送ajax请求,返回Promise实例
// function isExistUser(data) {
//     return ajaxPromise({
//         type: "get",
//         url: "http://121.43.116.41/demo/php/isExistUser.php",
//         data: data,
//         dataType: "json",
//     })
// }

// const isExistUser = function (data) {
//     return ajaxPromise({
//         type: "get",
//         url: "http://121.43.116.41/demo/php/isExistUser.php",
//         data: data,
//         dataType: "json",
//     })
// }

// const isExistUser = (data) => {
//     return ajaxPromise({
//         type: "get",
//         url: "http://121.43.116.41/demo/php/isExistUser.php",
//         data: data,
//         dataType: "json",
//     })
// }

const isExistUser = data => ajaxPromise({
    type: "get",
    url: "http://121.43.116.41/demo/php/isExistUser.php",
    data: data,
    dataType: "json",
});
const isExistPhone = data => ajaxPromise({
    type: "get",
    url: "http://121.43.116.41/demo/php/isExistPhone.php",
    data: data,
    dataType: "json",
});

const isExistEmail = data => ajaxPromise({
    type: "get",
    url: "http://121.43.116.41/demo/php/isExistEmail.php",
    data: data,
    dataType: "json",
});

const register = data => ajaxPromise({
    type: "post",
    url: "http://121.43.116.41/demo/php/register.php",
    data: data,
    dataType: "json"
})

const loginAccount = data => ajaxPromise({
    type: "post",
    url: "http://121.43.116.41/demo/php/login_account.php",
    data: data,
    dataType: "json"
})

const searchGradeOrderLimit = data => ajaxPromise({
    type: "get",
    url: "http://121.43.116.41/demo/php/searchGradeOrderLimit.php",
    data: data,
    dataType: "json",
});

const searchGradeById = data => ajaxPromise({
    type: "get",
    url: "http://121.43.116.41/demo/php/searchGradeById.php",
    data: data,
    dataType: "json",
});

const deleteGradeById = data => ajaxPromise({
    type: "get",
    url: "http://121.43.116.41/demo/php/deleteGradeById.php",
    data: data,
    dataType: "json",
});

const updateGradeById = data => ajaxPromise({
    type: "post",
    url: "http://121.43.116.41/demo/php/updateGradeById.php",
    data: data,
    dataType: "json",
});




